﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.Web.UI;

namespace Acme.TestSite.Objects
{
	[ToolboxItem(false)]
	public class BasePage : System.Web.UI.Page
	{
		protected List<Control> GetAllPageControls()
		{
			var retval = new List<Control>();
			AddControls(this.Page.Controls, retval);
			return retval;
		}

		private void AddControls(ControlCollection page, List<Control> controlList)
		{
			foreach (Control c in page)
			{
				if (c.ID != null)
				{
					controlList.Add(c);
				}

				if (c.HasControls())
				{
					AddControls(c.Controls, controlList);
				}
			}
		}

	}
}
